const mongoose = require("mongoose")
const { Schema, model } = mongoose

const ReservesSchema = new Schema({
    id_reserve: {
        type: Number,
        unique: true,
        required: [true,"需要剧本ID"],
    },
    id_play:{
        type: Schema.Types.ObjectId,
        ref:"Plays",
        required: true
    },
    initiator:{
        type: Schema.Types.ObjectId,
        ref:"Users",
        required: true
    },
    starttime:{
        type:Date,
        default:new Date().setDate(new Date().getDate()+1),
        required: true

    },
    is_allow:{
        type:Boolean,
        default:false
    }
    ,is_played:{
        type:Boolean,
        default:false
    },
    member:{
        type: [Schema.Types.ObjectId],
        ref:"Users",
    },
    num_limit:{
        type:Number,
        default:0
    }

}, { timestamps: true, versionKey: false })

module.exports = model("Reserves", ReservesSchema, "Reserves")